#include "md5manager.h"
#include <QCryptographicHash>
Md5Manager::Md5Manager() {}


QString Md5Manager::md5Encode(QString str) {
    QString md5;
    QByteArray bb;
    // QByteArray ba;
    // ba.append(str);
    //QByteArrayView
    bb = QCryptographicHash::hash ( str.toLatin1(), QCryptographicHash::Md5 );
    md5.append(bb.toHex());
    return md5;
}

QString Md5Manager::base64Encode(QString str) {
    return str.toLatin1().toBase64();
}

/**
 * toUtf8和toLatin有什么区别?
 * @brief Md5Manager::base64Decode
 * @param base64String
 * @return
 */
QString Md5Manager::base64Decode(QString base64String) {
    QByteArray ba = QByteArray::fromBase64(base64String.toUtf8());
    return ba;
}
